package com.jf.docsify.modules.system.user;

import com.jf.docsify.common.annotation.NotAuth;
import com.jf.docsify.common.utils.Resp;
import com.jf.docsify.modules.model.SysUser;
import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.jfinal.core.Path;
import com.jfinal.kit.JsonKit;

/**
 * Description: 用户控制层
 *
 * @author chenwr
 * @version 1.0
 *
 * <pre>
 * 修改记录:
 * 修改后版本           修改人       修改日期         修改内容
 * 2022/7/26.1       chenwr    2022/7/26           Create
 * </pre>
 * @date 2022/7/26
 */
@Path("/user")
public class UserController extends Controller {

    @Inject
    UserService userService;

    @NotAuth
    public void register() {
        String rawData = getRawData();
        SysUser sysUser = JsonKit.parse(rawData, SysUser.class);
        boolean register = userService.register(sysUser);
        Resp.resp(register).done(this);
    }

    public void update() {
        String rawData = getRawData();
        SysUser sysUser = JsonKit.parse(rawData, SysUser.class);
        boolean updateFlag = userService.update(sysUser);
        Resp.resp(updateFlag).done(this);
    }

    public void delete(SysUser sysUser) {
        userService.delete(sysUser);
    }

}